<template>
  <div>
      <!-- 图表页 -->
      <div ref="tu" style="width:1000px;height:400px;border:1px solid #000;"></div>
  </div>
</template>

<script>
// // 引入 ECharts 主模块
var echarts = require('echarts/lib/echarts');
// // 引入柱状图
require('echarts/lib/chart/bar');
// 引入提示框和标题组件
require('echarts/lib/component/tooltip');
require('echarts/lib/component/title');
export default {
    props:{
        y:Array,
        xX:Array,
        xD:Array,
        xG:Array,
    },
    data(){
        return{
            
        }
    },
    
    mounted(){
         // 基于准备好的dom，初始化echarts实例
        var myChart = echarts.init(this.$refs.tu);
   var option = {
       forceFit :true,
       width:800,
    title: {
        text: '走势图',
        subtext: '用户'
    },
    tooltip: {
        trigger: 'axis'
    },
    legend: {
        data: ['新注册用户', '新增订单','新增管理员']
    },
    toolbox: {
        show: true,
        feature: {
            dataZoom: {
                yAxisIndex: 'none'
            },
            dataView: {readOnly: false},
            magicType: {type: ['line', 'bar']},
            restore: {},
            saveAsImage: {}
        }
    },
    xAxis: {
        type: 'category',
        boundaryGap: false,
        data: this.y //七天日期
    },
    yAxis: {
        type: 'value',
        axisLabel: {
            formatter: '{value}'
        }
    },
    series: [
        {
            name: '新注册用户',
            type: 'line',
            data: this.xX,
            markPoint: {
                data: [
                    {type: 'max', name: '最大值'},
                    {type: 'min', name: '最小值'}
                ]
            },
            markLine: {
                data: [
                    {type: 'average', name: '平均值'}
                ]
            }
        },
        {
            name: '新增订单',
            type: 'line',
            data: this.xD,
            markPoint: {
                data: [
                    {name: '周最低', value: -2, xAxis: 1, yAxis: -1.5}
                ]
            },
            markLine: {
                data: [
                    {type: 'average', name: '平均值'},
                    [{
                        symbol: 'none',
                        x: '90%',
                        yAxis: 'max'
                    }, {
                        symbol: 'circle',
                        label: {
                            position: 'start',
                            formatter: '最大值'
                        },
                        type: 'max',
                        name: '最高点'
                    }]
                ]
            }
        },
                {
            name: '新增管理员',
            type: 'line',
            data: this.xG,
            markPoint: {
                data: [
                    {type: 'max', name: '最大值'},
                    {type: 'min', name: '最小值'}
                ]
            },
            markLine: {
                data: [
                    {type: 'average', name: '平均值'}
                ]
            }
        },
    ]
};

     // 使用刚指定的配置项和数据显示图表。
        myChart.setOption(option);
    },
    methods:{
        
    }
}
</script>

<style>

</style>
